package genalgoritm.actions;
import genalgoritm.count.Count;
import genalgoritm.editors.ResultEditor;
import genalgoritm.editors.ResultEditorInput;

import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.ui.PartInitException;
import org.eclipse.ui.PlatformUI;


public class RunCommand extends AbstractHandler {

	@Override
	public Object execute(ExecutionEvent event) throws ExecutionException {
		Count c = new Count();
		c.count();
		ResultEditorInput input = new ResultEditorInput(c.getResults());
		try {
			PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage()
					.openEditor(input, ResultEditor.ID);
		} catch (PartInitException e) {
			e.printStackTrace();
		}
		return null;
	}

	

}
